<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>销售单</title>
	<link rel="stylesheet" href="/css/modules.css" type="text/css"	media="screen" />
	<link rel="stylesheet" href="/css/modules1.css" type="text/css"	media="screen" />
	<link rel="stylesheet" href="/css/jquery-ui.css" type="text/css"	media="screen" />
	<link rel="stylesheet" href="/css/jquery.wysiwyg.css" type="text/css"	media="screen" />
	<style type="text/css">
		label{
			display:inline;
		}
		#addSellOrder #orderForm .input-small{
			border:none;
			background-color:transparent;
		}
		#addSellOrder .noborderSelect{
			border:none;
			background-color:transparent;
			width:100%;
		}
		#addSellOrder #orderForm td{
			padding:0;
			text-align:center;
		}
		#addSellOrder td_withPadding{
			padding:6px 6px 6px 12px;
		}
		#addSellOrder #customerDetail td{
			padding:6px 6px 6px 12px;
			text-align:left;
			font-size:14px;
		}
		#addSellOrder th{
			text-align:center;
		}
		#addSellOrder .td_first{
		background: url("/images/highlight_line.gif") repeat-x scroll 0 0 #EAEAEA;
		}
		#addSellOrder #selectCustomer{
			display:none;
		}
		#addSellOrder h4{
			color:#CCC;
			font-size:12px;
			padding:10px;
			font-style:italic;
		}
		#addSellOrder #createCustomer{
			display:none;
		}
	</style>
	<script type='text/javascript' src="/js/jquery-1.4.2.min.js"></script>	
	<script type='text/javascript' src="/js/jquery.js"></script>
	<script type='text/javascript' src="/js/jquery-ui.js"></script>
	<script type='text/javascript' src="/js/jquery.wysiwyg.js"></script>
	<script type='text/javascript' src="/js/custom.js"></script>
	<script type="text/javascript" src="/js/order.js"></script>
	<script type="text/javascript">
		var url;
		var dialogOption={height: 350,width:880,modal:true,position: [50,50]};
		function addSellOrder(){
			jQuery("#addSellOrder").dialog(dialogOption);
			jQuery("#addSellOrder").dialog("open");
		}
		function colseDialog(){
			jQuery("#addSellOrder").dialog();
			jQuery("#addSellOrder").dialog("close");
		}
		function viewSellOrder(f){
			var loadUrl="/OrderAction!view.action?id="+$(f).prev().val()+"&t="+new Date().getTime();
			$("#viewSellOrder").load(loadUrl,function(){
				jQuery("#viewSellOrder").dialog(dialogOption);
				jQuery("#viewSellOrder").dialog("open");
			});
		}
		function deleteSellOrder(f){
			if(window.confirm("您确定要删除此订单的信息吗?")){
				var del_url="/OrderAction!del.action?id="+$(f).prev().prev().val()+"&t="+new Date().getTime();
     			$.ajax({url:del_url,success:function(){
     				$(f).parent().parent().remove();
     				alert("订单删除成功!");
     			}});
			}
		}
	</script>
  </head>
  
  <body style="background-color:transparent">
	<!--  Goods_list header -->
	<div style="padding:10px;">
  		<h2 class="jquery_tab_title">销售单列表
  		</h2>
  		<input type="button" style="margin:10px;" value="+新建销售单" class="button" onclick="addSellOrder();" />
  	</div>
  	<!--  Goods_list  -->
  	<div>
  	<table width="100%" cellspacing="0" cellpadding="0">
  		<tr>
  			<th class="th_first"><input type="checkbox" /></th>
  			<th>单据日期</th>
  			<th>单据编号</th>
  			<th>销售人员</th>
  			<th>收款金额</th>
  			<th>售出总数量</th>
  			<th>说明</th>
  			<th>操作</th>
  		</tr>
  		<s:iterator value="orderList">
    	<tr>
    		<td class="td_first"><input type="checkbox" /></td>
    		<td><s:date name="date" format="yyyy-MM-dd HH:mm" />&nbsp;</td>
    		<td>${code }&nbsp;</td>
    		<td>${operator.realname }&nbsp;</td>
    		<td>${amount }&nbsp;</td>
    		<td>${totalQuantity }&nbsp;</td>
    		<td>${remark }&nbsp;</td>
    		<td>
    			<input type="hidden" value="${id }" />
    			<a href="##" onclick="viewSellOrder(this);">详细信息</a>
    			<a href="##" onclick="deleteSellOrder(this);">删除</a>
    		</td>
    	</tr>
    	</s:iterator>
  		
  	</table>
  	<div style="text-align:right;padding:20px;">${pagination }</div>
    </div>
    
    
    <!--  新建销售单 弹出层  -->
	 
	<div id="addSellOrder" style="display:none;padding-top:20px;" title="新建销售单">
		<form id="orderForm" action="/OrderAction!createSellOrder.action" method="post" onsubmit="this.validate()">
    	<input id="hCustomerid" type="hidden" name="outletsid" />
    	<table  width="100%" cellspacing="0" cellpadding="0">
    		<tr>
    			<th class="th_first">行号</th>
    			<th width="30%">货物名称</th>
    			<th width="20%">数量</th>
    			<th>单价</th>
    			<th>金额</th>
    			<th>备注</th>
    		</tr>
    		<tr>
    		<tr>
    			<td class="td_first">1</td>
    			<td>
    				<s:select name="productid" list="productList" listKey="id" listValue="name"
    				 theme="simple" cssClass="noborderSelect" onchange="loadProductInfo(this);" 
    				 headerKey="" headerValue="请选择货品" ></s:select>
    			</td>
    			<td><input type="text" name="quantity" style="IME-MODE: disabled;" onkeyup="(this.v=function(){this.value=this.value.replace(/\D/g,'');}).call(this)" onblur="this.v();" class="input-small" /></td>
    			<td><input type="text" name="price"  class="input-small" /></td>
    			<td><input type="text" name="amounts"  class="input-small" /></td>
    			<td><input type="text" name="unit"  class="input-small" /></td>
    		</tr>
    		<tr>
    		<td class="td_first">2</td>
    			<td>
					<s:select name="productid" list="productList" listKey="id" listValue="name"
    				 theme="simple" cssClass="noborderSelect" onchange="loadProductInfo(this);" 
    				 headerKey="" headerValue="请选择货品" ></s:select>
    			</td>
    			<td><input type="text" name="quantity"  class="input-small"  /></td>
    			<td><input type="text" name="price"  class="input-small" /></td>
    			<td><input type="text" name="amounts"  class="input-small" /></td>
    			<td><input type="text" name="unit"  class="input-small" /></td>
    		</tr>
    		<tr>
    			<td class="td_first">3</td>
    			<td>
    				<s:select name="productid" list="productList" listKey="id" listValue="name"
    				 theme="simple" cssClass="noborderSelect" onchange="loadProductInfo(this);" 
    				 headerKey="" headerValue="请选择货品" ></s:select>
    			</td>
    			<td><input type="text" name="quantity"  class="input-small"  /></td>
    			<td><input type="text" name="price"  class="input-small" /></td>
    			<td><input type="text" name="amounts"  class="input-small" /></td>
    			<td><input type="text" name="unit"  class="input-small" /></td>
    		</tr>
    		<tr>
    			<td class="td_first">4</td>
    			<td>
    				<s:select name="productid" list="productList" listKey="id" listValue="name"
    				 theme="simple" cssClass="noborderSelect" onchange="loadProductInfo(this);" 
    				 headerKey="" headerValue="请选择货品" ></s:select>
    			</td>
    			<td><input type="text" name="quantity"  class="input-small"  /></td>
    			<td><input type="text" name="price"  class="input-small" /></td>
    			<td><input type="text" name="amounts"  class="input-small" /></td>
    			<td><input type="text" name="unit"  class="input-small" /></td>
    		</tr>
    		<tr>
    			<td class="td_first">5</td>
    			<td>
    				<s:select name="productid" list="productList" listKey="id" listValue="name"
    				 theme="simple" cssClass="noborderSelect" onchange="loadProductInfo(this);" 
    				 headerKey="" headerValue="请选择货品" ></s:select>
    			</td>
    			<td><input type="text" name="quantity"  class="input-small"  /></td>
    			<td><input type="text" name="price"  class="input-small" /></td>
    			<td><input type="text" name="amounts"  class="input-small" /></td>
    			<td><input type="text" name="unit"  class="input-small" /></td>
    		</tr>
    		<tr>
    			<td class="td_first">6</td>
    			<td>
    				<s:select name="productid" list="productList" listKey="id" listValue="name"
    				 theme="simple" cssClass="noborderSelect" onchange="loadProductInfo(this);" 
    				 headerKey="" headerValue="请选择货品" ></s:select>
    			</td>
    			<td><input type="text" name="quantity"  class="input-small"  /></td>
    			<td><input type="text" name="price"  class="input-small" /></td>
    			<td><input type="text" name="amounts"  class="input-small" /></td>
    			<td><input type="text" name="unit"  class="input-small" /></td>
    		</tr>
    		
    		<tr>
    			<td class="td_first" style="padding:6px 6px 6px 12px;">合计</td>
    			<td class="td_withPadding" id="_productInfo" style="color:red">&nbsp;</td>
    			<td class="td_withPadding">&nbsp;</td>
    			<td class="td_withPadding">&nbsp;</td>
    			<td class="td_withPadding">&nbsp;</td>
    			<td class="td_withPadding">&nbsp;</td>
    		</tr>
    		
    	</table>
    	<div style="text-align:right;padding:20px;">
    		<input type="button" value="添加一行记录" class="button" onclick="addColume();" />
    		<input type="submit" value="保存并新增" class="button" />
    		<input type="button" value="取消" class="button" onclick="colseDialog();" />
    	</div>
    </form>
	</div> 
	
	<!--  查看销售单 弹出层  -->
	<div id="viewSellOrder" style="display:none;padding-top:20px;" title="查看销售单"></div>
	
  </body>
</html>
